<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class template wrapping_int</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../date_time/doxy.html#doxygen.date_time_reference.wrapping__int_8hpp" title="Header &lt;boost/date_time/wrapping_int.hpp&gt;">
<link rel="prev" href="classboost_1_1date__time_1_1tz__db__base.html" title="Class template tz_db_base">
<link rel="next" href="classboost_1_1date__time_1_1wrapping__int2.html" title="Class template wrapping_int2">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="classboost_1_1date__time_1_1tz__db__base.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#doxygen.date_time_reference.wrapping__int_8hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="classboost_1_1date__time_1_1wrapping__int2.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template wrapping_int</span></h2>
<p>boost::date_time::wrapping_int — A wrapping integer used to support time durations (WARNING: only instantiate with a signed type) </p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../date_time/doxy.html#doxygen.date_time_reference.wrapping__int_8hpp" title="Header &lt;boost/date_time/wrapping_int.hpp&gt;">boost/date_time/wrapping_int.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> int_type_<span class="special">,</span> <span class="identifier">int_type_</span> wrap_val<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html" title="Class template wrapping_int">wrapping_int</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">int_type_</span> <a name="doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1aae93d0f708b4f242bcfd3a0dc8e548ed"></a><span class="identifier">int_type</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html#id-1_3_11_15_3_59_1_1_1_5-bb">public static functions</a></span>
  <span class="keyword">static</span> <span class="identifier">BOOST_CONSTEXPR</span> <span class="identifier">int_type</span> <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html#doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1ad8c21bed6dbf7b4594c8f861b54569cd"><span class="identifier">wrap_value</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html#id-1_3_11_15_3_59_1_1_1_6-bb">public member functions</a></span>
  <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html#doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1a8f45cbc9a5fddc8a361b4baf8075ac79"><span class="identifier">wrapping_int</span></a><span class="special">(</span><span class="identifier">int_type</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">BOOST_CONSTEXPR</span> <span class="identifier">int_type</span> <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html#doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1a2ba0a3d4b8e80a2c3b0a6a7a28c49759"><span class="identifier">as_int</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">BOOST_CONSTEXPR</span> <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html#doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1a0b7010f0a946b37af026a8d804e4f3f4"><span class="keyword">operator</span> <span class="identifier">int_type</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">IntT</span> <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html#doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1ae8e8f9924d20543c7b6f873d17bad5ec"><span class="identifier">add</span></a><span class="special">(</span><span class="identifier">IntT</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">IntT</span> <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html#doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1a524fb748d0238aaec25d9730908fb642"><span class="identifier">subtract</span></a><span class="special">(</span><span class="identifier">IntT</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html#id-1_3_11_15_3_59_1_1_1_7-bb">private member functions</a></span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">IntT</span> <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html#doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1adb41f5487e01083f0e90468fbd93c2a8"><span class="identifier">calculate_wrap</span></a><span class="special">(</span><span class="identifier">IntT</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.11.15.3.58.3.4"></a><h2>Description</h2>
<p>In composite date and time types this type is used to wrap at the day boundary. Ex: A wrapping_int&lt;short, 10&gt; will roll over after nine, and roll under below zero. This gives a range of [0,9]</p>
<p>NOTE: it is strongly recommended that <a class="link" href="classboost_1_1date__time_1_1wrapping__int2.html" title="Class template wrapping_int2">wrapping_int2</a> be used instead of <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html" title="Class template wrapping_int">wrapping_int</a> as <a class="link" href="classboost_1_1date__time_1_1wrapping__int.html" title="Class template wrapping_int">wrapping_int</a> is to be depricated at some point soon.</p>
<p>Also Note that warnings will occur if instantiated with an unsigned type. Only a signed type should be used! </p>
<div class="refsect2">
<a name="id-1.3.11.15.3.58.3.4.5"></a><h3>
<a name="id-1_3_11_15_3_59_1_1_1_5-bb"></a><code class="computeroutput">wrapping_int</code> public static functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">BOOST_CONSTEXPR</span> <span class="identifier">int_type</span> <a name="doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1ad8c21bed6dbf7b4594c8f861b54569cd"></a><span class="identifier">wrap_value</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li></ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.11.15.3.58.3.4.6"></a><h3>
<a name="id-1_3_11_15_3_59_1_1_1_6-bb"></a><code class="computeroutput">wrapping_int</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1a8f45cbc9a5fddc8a361b4baf8075ac79"></a><span class="identifier">wrapping_int</span><span class="special">(</span><span class="identifier">int_type</span> v<span class="special">)</span><span class="special">;</span></pre>Add, return true if wrapped. </li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">BOOST_CONSTEXPR</span> <span class="identifier">int_type</span> <a name="doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1a2ba0a3d4b8e80a2c3b0a6a7a28c49759"></a><span class="identifier">as_int</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Explicit converion method. </li>
<li class="listitem"><pre class="literallayout"><span class="identifier">BOOST_CONSTEXPR</span> <a name="doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1a0b7010f0a946b37af026a8d804e4f3f4"></a><span class="keyword">operator</span> <span class="identifier">int_type</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">IntT</span> <a name="doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1ae8e8f9924d20543c7b6f873d17bad5ec"></a><span class="identifier">add</span><span class="special">(</span><span class="identifier">IntT</span> v<span class="special">)</span><span class="special">;</span></pre>Add, return number of wraps performed. <p>The sign of the returned value will indicate which direction the wraps went. Ex: add a negative number and wrapping under could occur, this would be indicated by a negative return value. If wrapping over took place, a positive value would be returned </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">IntT</span> <a name="doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1a524fb748d0238aaec25d9730908fb642"></a><span class="identifier">subtract</span><span class="special">(</span><span class="identifier">IntT</span> v<span class="special">)</span><span class="special">;</span></pre>Subtract will return '+d' if wrapping under took place ('d' is the number of wraps) <p>The sign of the returned value will indicate which direction the wraps went (positive indicates wrap under, negative indicates wrap over). Ex: subtract a negative number and wrapping over could occur, this would be indicated by a negative return value. If wrapping under took place, a positive value would be returned. </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.11.15.3.58.3.4.7"></a><h3>
<a name="id-1_3_11_15_3_59_1_1_1_7-bb"></a><code class="computeroutput">wrapping_int</code> private member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> IntT<span class="special">&gt;</span> <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">IntT</span> <a name="doxygen.date_time_reference.classboost_1_1date__time_1_1wrapping__int_1adb41f5487e01083f0e90468fbd93c2a8"></a><span class="identifier">calculate_wrap</span><span class="special">(</span><span class="identifier">IntT</span> wrap<span class="special">)</span><span class="special">;</span></pre></li></ol></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
    <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="classboost_1_1date__time_1_1tz__db__base.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#doxygen.date_time_reference.wrapping__int_8hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="classboost_1_1date__time_1_1wrapping__int2.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
